<?
if (!defined ('L_MOD')) {die("<h3>You can`t access this file...</h3>");}

if(isset($cid) && is_numeric($cid) && $cid!='')
{
	$query_cat=mysql_query("SELECT * FROM ${wcpref}".$nma."_category");
	if (mysql_num_rows($query_cat)<0)
	{
		print '<br><br><center><b><font color="#FF0000">'._ERROR_.'</font> '._ERRORCIDCAT_.'</b></center>';
		echo "<meta http-equiv='refresh' content='2; url=/index.php?nma=".$nma."&fla=index'>";
	}else
	{
		$quik_select='<form name="form" method="get" action="index.php">
			<input type="hidden" name="nma" value="'.$nma.'">
			<input type="hidden" name="fla" value="'.$fla.'">
			<select name="cid">';
		while($result_cat=mysql_fetch_array($query_cat))
		{
			extract($result_cat);
			if ($mod_id==$cid)
			{
				$mod_18_new=$mod_18;
				$name_category=$mod_category;
				$select='selected';
			}else
				$select='';
			if($wccat_allow18plus==0 && $mod_18==1)
			{
			}else
				$quik_select.='	<option value="'.$mod_id.'" '.$select.'>'.$mod_category;
		}
			$quik_select.='</select> <input type="Submit" value="'._GOTOCAT_.'">
		</form>';
		//extract(mysql_fetch_array($query_cat));
		if($wccat_allow18plus==0 && $mod_18_new==1)
		{
			print '<br><br><center><b><font color="#FF0000">'._ERROR_.'</font> '._ERRORCIDCAT_.'</b></center>';
			echo "<meta http-equiv='refresh' content='2; url=/index.php?nma=".$nma."&fla=index'>";
		}else
		{
			print "<h2>".$name_category."</h2><br>";
			print '<table align="right">
				<tr>
					<td>'.$quik_select.'</td>
				</tr>
			</table><br>';
			$query=mysql_query("SELECT * FROM ${wcpref}".$nma." WHERE mod_cat_id='".$cid."' and mod_block='0' and mod_ban='0'");
			if (mysql_num_rows($query)>0)
			{
				$d=0;
				while ($result=mysql_fetch_array($query))
				{
					$d++;$iclass = ($d % 2) ? "even" : "odd";
					extract($result);
					$dat=date('d.m.Y H:i', strtotime($mod_dat));
					if($mod_full!='')
					{
						$a_beg='<a href="?nma='.$nma.'&fla=full&sid='.$mod_id.'" title="'._FULLOPIS_.'">';
						$a_end="</a>";
					}else
					{
						$a_beg='';
						$a_end="";
					}
					if ($mod_wcps==1)
						$wcpslink='<a href="http://wcps.ru" target="_blank" title="'._UNDERWCPS_.'"><img src="/images/'.$nma.'/wcpsimg.gif" border="0"></a>';
					else
						$wcpslink='';
					
					if ($mod_wcps==1)
					{
						if($_SESSION['urov']==1)
						{
							$adminColspan='';
							$editLinkAdmin='<td><a href="index.php?nma='.$nma.'&fla=edwcpssite&sid='.$mod_id.'"><img src="/images/'.$nma.'/text_signature.png" border="0" title="'._EDIT_.'"></a></td>';
						}
						else
						{
							$adminColspan='colspan="2"';
							$editLinkAdmin='';
						}
					}else
					{
						$adminColspan='colspan="2"';
						$editLinkAdmin='';
					}
					
					if ($mod_map==1)
					{
						$rowspan='3';
						$mapRow='<tr>
							<td align="center" valign="top">
								<a href="index.php?nma='.$nma.'&fla=maps&item=wcpssite&sid='.$mod_id.'" title="'._MAPSSITE_.'">
									<img src="/images/'.$nma.'/chart_organisation.png" border="0">
								</a>
							</td>
						</tr>';
					}else
					{
						$rowspan='2';
						$mapRow='';
					}
					
					print'<table align="center" border="0" cellpadding="2" cellspacing="2" width="100%" class="'.$iclass.'">
						<tr>
							'.$editLinkAdmin.'
							<td '.$adminColspan.' align="center"><b>'.$a_beg.''.$mod_name.''.$a_end.'</b></td>
							<td align="center"><i>'._ADDED_.': '.$dat.'</i></td>
						</tr>
						<tr>
							<td rowspan="'.$rowspan.'" colspan="2" title="'._SHORTOPIS_.'" width="64%">'.$mod_short.'</td>
							<td align="center">'.$wcpslink.'</td>
						</tr>
						'.$mapRow.'
						<tr>
							<td align="center" valign="top"><a href="http://'.$mod_url.'" target="_blank" title="'._GOTOSITE_.'">http://'.$mod_url.'</a></td>
						</tr>
					</table>';
				}
			}elseif(mysql_num_rows($query)==0)
				print '<br><br><center><b>'._ZEROLINKCAT_.'</b></center>';
			print '<br><table>
				<tr>
					<td align="left">
						<a href="?nma='.$nma.'&fla=index">'._TOCATEGORY_.'</a>&nbsp;&nbsp;
					</td>
				</tr>
			</table>';
			print '<br><br><table align="center" border="0" cellpadding="1" cellspacing="1">
				<tr>';
					if($_SESSION['auth']==1)
					{
						print'<td align="center">
							<a href="?nma='.$nma.'&fla=mysites">'._MYSITES_.'</a>&nbsp;&nbsp;
						</td>';
					}
					print'<td align="center">
						&nbsp;&nbsp;<a href="'.$wccat_service_url.'/index.php?nma=wccat&fla=addwcsite&cid='.$cid.'">'._ADDWCPSSITE_.'</a>&nbsp;&nbsp;
					</td>
					<td align="center">';
						if ($wccat_allowadd==1)
							print'&nbsp;&nbsp;<a href="?nma='.$nma.'&fla=addsite&cid='.$cid.'">'._ADDOTHERSITE_.'</a>';
					print'</td>
				</tr>
			</table>';
		}
	}
}else
{
	print '<br><br><center><b><font color="#FF0000">'._ERROR_.'</font> '._ERRORCIDCAT_.'</b></center>';
	echo "<meta http-equiv='refresh' content='2; url=/index.php?nma=".$nma."&fla=index'>";
}
?>